package com.users.rn.rncommon.network;//package com.users.rn.common.network;
//
//import com.users.health.network.request.RequestListener;
//import com.google.gson.Gson;
//
//import java.lang.reflect.Type;
//import java.util.concurrent.TimeUnit;
//
//import io.reactivex.Observable;
//import io.reactivex.android.schedulers.AndroidSchedulers;
//import io.reactivex.schedulers.Schedulers;
//import okhttp3.OkHttpClient;
//import retrofit2.Retrofit;
//import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
//import retrofit2.converter.fastjson.FastJsonConverterFactory;
//
///**
// * @Description:
// * @Author: bluce
// * @Date: 2020/12/3 16:01
// */
//public final class ALHNetworkManager {
//    private static Retrofit retrofit;
//
//    public static <T> T create(Class<T> service) {
//        return retrofit.create(service);
//    }
//
//    public void init(String baseUrl) {
//        if (retrofit == null) {
//            OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                    .writeTimeout(30_1000, TimeUnit.MICROSECONDS)
//                    .readTimeout(20_1000, TimeUnit.MILLISECONDS)
//                    .connectTimeout(15_1000, TimeUnit.MILLISECONDS)
////                    .addInterceptor()
//                    .build();
//            retrofit = new Retrofit.Builder()
//                    .baseUrl(baseUrl)
//                    .addConverterFactory(FastJsonConverterFactory.create())
//                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
//                    .client(okHttpClient)
//                    .build();
//        }
//    }
//
//    public static <T> Observable<T> trans(Observable<T> observable) {
//        return observable.subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread());
//    }
//
//
//    //    public static void get(String url, final RequestListener listener) {
////        Request request = new Request.Builder()
////                .url(url)
////                .build();
////        httpClient.newCall(request).enqueue(
////                new Callback() {
////                    @Override
////                    public void onFailure(@NotNull Call call, @NotNull IOException e) {
////                        listener.onError(e.getMessage());
////                    }
////
////                    @Override
////                    public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
////                        listener.onSuccess(response.body().string());
////                    }
////                }
////        );
////    }
////
////    /**
////     * 模拟插件数据返回
////     *
////     * @param listener
////     */
//    public static void mockPluginInfo(Type type, RequestListener listener) {
//        String content = "[{\"ext\":{\"pluginType\":\"react_native\",\"isPartialBundle\":1},\"pluginVersion\":19115,\"pluginId\":\"RN_PADP_Medical_Pictor\",\"miniAppVersion\":10000,\"url\":\"packets/rn-pictor--android_20201202-163701.zip\",\"maxAppVersion\":0,\"md5\":\"9e172d6e9a54a87d54a0fc9296ebf4d8\"}]";
//        try {
//            listener.onSuccess(new Gson().fromJson(content, type));
//        } catch (Exception e) {
//            listener.onError(e.getLocalizedMessage());
//        }
//    }
//}
